package com.littleshu.test;

import java.util.Scanner;

/**
 * 题目：题目：求s=a+aa+aaa+aaaa+aa...a的值，其中a是一个数字。例如2+22+222+2222+22222(此时共有5个数相加)，
 * 几个数相加有键盘控制。1.程序###分析：关键是计算出每一项的值。
 * 
 * @author littleshu
 *
 */
public class Question8 implements RunTest {

	public static void main(String[] args) {
		new Question8().runTest();
	}

	@SuppressWarnings("resource")
	@Override
	public void runTest() {
		Scanner sc = new Scanner(System.in);
		System.out.println("请输入几个数要相加：");
		int count = Integer.valueOf((sc.nextLine()));
		int number = 2;
		int step = number;
		int value = number;

		System.out.print(step);
		for (int i = 1; i < count; i++) {
			System.out.print("+");
			step += (int) (2 * Math.pow(10, i));
			System.out.print(step);
			value += step;
		}
		System.out.println("的值是: " + value);
	}

}
